package com.system.presideover.controller;


import com.system.common.result.Result;
import com.system.presideover.entity.ContactNumber;
import com.system.presideover.entity.Officiate;
import com.system.presideover.service.OfficiateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 司仪类型 前端控制器
 * </p>
 *
 * @author system
 * @since 2024-04-16
 */
@Api(tags = "司仪类型")
@RestController
@RequestMapping("/presideover/officiate")
public class OfficiateController {

    @Autowired
    private OfficiateService officiateService;

    @ApiOperation(value = "司仪类型")
    @GetMapping("/listOfficiate")
    public Result listOfficiate(){
        List<Officiate> list = officiateService.list();
        return Result.ok(list);
    }

    @ApiOperation(value = "添加司仪类型")
    @PostMapping("/saveOfficiate")
    public Result saveOfficiate(@RequestBody Officiate accountNumber){
        boolean save = officiateService.save(accountNumber);

        if (save){
            return Result.ok().message("添加成功");
        }
        return Result.fail().message("添加失败");
    }


    @ApiOperation(value = "修改司仪类型")
    @PostMapping("/updateOfficiate")
    public Result updateOfficiate(@RequestBody Officiate accountNumber){
        boolean save = officiateService.updateById(accountNumber);

        if (save){
            return Result.ok().message("修改成功");
        }
        return Result.fail().message("修改失败");
    }

    @ApiOperation(value = "删除司仪类型")
    @PostMapping("/delectOfficiate")
    public Result delectOfficiate(@RequestBody Officiate accountNumber){
        boolean save = officiateService.removeById(accountNumber.getId());

        if (save){
            return Result.ok().message("删除成功");
        }
        return Result.fail().message("删除失败");
    }

}

